package com.tianji;

import cn.hutool.core.date.DateUtil;
import com.tianji.agent.AgentParams;
import com.tianji.config.SystemPromptConfig;
import com.tianji.constants.Constant;
import com.tianji.enums.AgentTypeEnum;
import com.tianji.service.impl.AbstractAgent;
import com.tianji.tools.CourseTools;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.advisor.api.Advisor;
import org.springframework.ai.chat.client.advisor.vectorstore.QuestionAnswerAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 课程咨询智能体
 */
@Component
@RequiredArgsConstructor
public class ConsultAgent extends AbstractAgent {


    private final SystemPromptConfig systemPromptConfig;

    private final QuestionAnswerAdvisor questionAnswerAdvisor;

    private final CourseTools courseTools;

    @Override
    public AgentTypeEnum getAgentType() {
        return AgentTypeEnum.CONSULT;
    }

    @Override
    public String systemMessage() {
        return systemPromptConfig.getConsultAgentSystemMessage().get();
    }

    @Override
    public Map<String, Object> systemMessageParams(AgentParams params) {
        return Map.of("now", DateUtil.now());
    }

    @Override
    public List<Advisor> advisors() {
        return List.of(questionAnswerAdvisor);
    }

    @Override
    public Object[] tools() {
        return new Object[]{courseTools};
    }

    @Override
    public Map<String, Object> toolContext(AgentParams params) {
        return  Map.of(Constant.REQUEST_ID,params.getRequestId(),
                Constant.USER_ID,params.getUserId());
    }


}